import bs4
import plotly.express as px
import pandas as pd

class Result_Parser:
    def __init__(self, raw_html_array, file_name_array) -> None:
        self.soups = []
        self.res_sets = []
        self.file_names = file_name_array
        self.req_per_sec_tags = []
        self.qps = []
        for raw_html in raw_html_array:
            self.soups.append(bs4.BeautifulSoup(raw_html, 'html.parser'))
        for soup in self.soups:
            self.res_sets.append(soup.find_all('tr'))
        for item in self.res_sets:
            self.req_per_sec_tags.append(item[11])
            self.qps.append(float(item[11].td.string))
    
    def showImg(self):
        df = pd.DataFrame({
            "file_name": self.file_names,
            "qps": self.qps
        })
        ifg = px.bar(df, x='file_name', y='qps')
        ifg.show()
